<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="${packageName}<#if moduleName?exists><#if moduleName!=''>.${moduleName}</#if></#if>.mapper.${entityName?cap_first}Mapper" >

  <sql id="Base_Column_List" >
    <#list columns as column>
    t.${column.columnName}<#if !column.isBaseType> AS "${column.javaField}.id"</#if><#if column_has_next>,</#if>
    </#list>
  </sql>
  
  	<!-- 批量插入 -->
  	<insert id="insertBatch">
  		insert into ${tableName} (<#list attributeInfos as column>${column.dbName}<#if column_has_next>,</#if></#list>)
    	values
    	<foreach collection ="list" item="item" separator =",">
         	(<#list attributeInfos as column>${"#"}{item.${column.name}}<#if column_has_next>,</#if></#list>)
    	</foreach >
  	</insert>	
  
  	<!-- 批量更新 -->
	<update id="updateBatch">
		update ${tableName} set 
		<#list attributeInfos as column>
		<#if column.dbName!='id'&&column.name!='createBy'&&column.name!='createDate'&&column.name!='updateBy'&&column.name!='updateDate'>
			${column.dbName} = 
			<foreach collection="list" item="item" index="index"
	            separator=" " open="case id" close="end">
	            when ${"#"}{item.id} then ${"#"}{item.${column.name}}
        	</foreach>
			<#if column_has_next>,</#if>
		</#if>
		</#list>
        where id in
        <foreach collection="list" item="item" index="index" separator="," open="(" close=")">
            ${"#"}{item.id}
        </foreach>
	</update>
  
</mapper>